package com.airy.highSpeed.controller;

import com.airy.highSpeed.entity.FlowTrafficEntity;
import com.airy.highSpeed.entity.RktxEntity;
import com.airy.highSpeed.service.FlowTrafficService;
import com.airy.highSpeed.service.RktxService;
import com.airy.highSpeed.utils.PageUtils;
import com.airy.highSpeed.utils.R;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author: Ding Ya Kun.
 * @Description:
 * @Date:Created in 2021.1.27 9:00
 */

@RestController
@RequestMapping("product/flowtraffic")
public class FlowTrafficController {
    @Autowired
    private FlowTrafficService flowTrafficService;

    /**
     * 查询所有
     */
    @RequestMapping("/findAll")
    public R findAll() {
        List<FlowTrafficEntity> flowTrafficEntityList = flowTrafficService.findAll();

        return R.ok().put("长度", flowTrafficEntityList.size());
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = flowTrafficService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id) {
        FlowTrafficEntity flowTraffic = flowTrafficService.getById(id);

        return R.ok().put("flowTraffic", flowTraffic);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody FlowTrafficEntity flowTraffic) {
        flowTrafficService.save(flowTraffic);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody FlowTrafficEntity flowTraffic) {
        flowTrafficService.updateById(flowTraffic);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] ids) {
        flowTrafficService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    public List<FlowTrafficEntity> find(String shijian, String bianhao) {
        return flowTrafficService.find(shijian, bianhao);
    }

    public List<FlowTrafficEntity> findBystartTimeAndTollStationIdAndFlage1(String thisWeekDateLastOneWeek, String thisWeekDateLastTwoWeek, String thisWeekDateLastThreeWeek, String thisWeekDateLastFourWeek, String tollStationId) {
        return flowTrafficService.findBystartTimeAndTollStationIdAndFlage1(thisWeekDateLastOneWeek, thisWeekDateLastTwoWeek, thisWeekDateLastThreeWeek, thisWeekDateLastFourWeek, tollStationId);
    }

    public List<FlowTrafficEntity> findBystartTimeAndTollStationIdAndFlage2(String thisWeekDateLastOneWeek, String thisWeekDateLastTwoWeek, String thisWeekDateLastThreeWeek, String thisWeekDateLastFourWeek, String tollStationId) {
        return flowTrafficService.findBystartTimeAndTollStationIdAndFlage2(thisWeekDateLastOneWeek, thisWeekDateLastTwoWeek, thisWeekDateLastThreeWeek, thisWeekDateLastFourWeek, tollStationId);
    }

    public List<FlowTrafficEntity> findBySTARTTIMEAndTOLLSTATIONID(String startTime, String tollStationId) {
        return flowTrafficService.findBySTARTTIMEAndTOLLSTATIONID(startTime,tollStationId);
    }
}
